package com.example.education.Mapper;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.education.Bean.ForeignCollegeInfo;
import com.example.education.Bean.StudentInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 姚
 * @since 2023-03-27
 */

@Mapper
public interface ForeignCollegeInfoMapper extends BaseMapper<ForeignCollegeInfo> {

    //增
    @Insert("INSERT into foreign_college_info(uid,college_Name,introduction,department,location,application_Condition,ielts_Requirement,application_Speed,admission_Ratio,tuition_Fee,living_Expenses,qs_Ranking) values" +
            " (#{uid},#{collegeName},#{introduction},#{department},#{location},#{applicationCondition},#{ieltsRequirement},#{applicationSpeed}," +
            "#{admissionRatio},#{tuitionFee},#{livingExpenses},#{qsRanking})")
    int insert(ForeignCollegeInfo foreignCollegeInfo);

    //删
    @Delete("DELETE FROM Foreign_College_Info WHERE uid=#{uid}")
    int delete(Integer uid);

    //根据地区查相应的所有学校
    @Select("SELECT * FROM Foreign_College_Info WHERE location=#{location}")
    ArrayList<ForeignCollegeInfo> selectByLocation(String location);

    //根据名字查找学校
    @Select("SELECT * FROM Foreign_College_Info WHERE college_Name=#{collegeName}")
    ForeignCollegeInfo selectByName(String collegeName);

    //改
    int update(ForeignCollegeInfo foreignCollegeInfo, UpdateWrapper<StudentInfo> updateWrapper);

    //根据qs查找学校
    @Select("SELECT * FROM Foreign_College_Info WHERE qs_Ranking=#{qsRanking}")
    ForeignCollegeInfo selectByQsRanking(double qsRanking);
}
